{include file="public/header" /}

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <!-- <div class="layui-card-body ">
                    <ul class="layui-row layui-col-space10 layui-this x-admin-carousel x-admin-backlog">

                    </ul>
                </div> -->
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5">
                        <div class="layui-inline layui-show-xs-block">
                            <select name="daotype" lay-filter="daotype">
                                <option value="1">搜索（选择搜索后点击[搜索|导出]按钮就行筛选搜索）</option>
                                <option value="2">导出（选择导出后点击[搜索|导出]按钮就行筛选导出）</option>
                            </select>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <select name="type">
                                <option value="">币种类型</option>
                                {if !empty($coin)}
                                {foreach $coin as $k => $coins}
                                <option value="{$k}" {if !empty(input('get.type')) &&
                                    input('get.type')==$k}selected{/if}>{$coins}</option>
                                {/foreach}
                                {/if}
                            </select>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="mobile" placeholder="用户手机号|ID" value="{:input('get.mobile')}"
                                autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn" lay-submit="" lay-filter="sreach">搜索</button>
                        </div>
                    </form>
                </div>
                <div class="layui-card-header">
                    共有数据：<strong id="count">{$list->total()}</strong> 条
                </div>
                <div class="layui-card-body layui-table-body layui-table-main">
                    <table class="layui-table layui-form">
                        <thead>
                            <tr>
                                <th width="250">用户信息</th>
                                <th width="100">币种类型</th>
                                <th width="250">金额</th>
                                <th width="100">锁仓金额</th>
                            </tr>
                        </thead>
                        <tbody>
                            {foreach $list as $v}
                            <tr>
                                <td>ID:{$v.user_id|default='0'}<br />手机号:{$v.mobile|default=''}</td>
                                <td>{$v.typetext|default=''}</td>
                                <td>{$v.money|default='0'}&nbsp;
                                    <button type="button"
                                        onclick="orderstr('/user/money_edit','{$v.user_id}','{$v.type}')"
                                        class="layui-btn layui-btn-xs">
                                        <i class="layui-icon">&#xe654;</i>
                                    </button>
                                </td>
                                <td>{$v.freezemoney|default='0'}</td>
                            </tr>
                            {/foreach}

                        </tbody>
                    </table>
                </div>
                <div class="layui-card-body ">
                    <div class="page">
                        {$list->render()|raw}
                    </div>
                </div>

            </div>
        </div>
    </div>
</div>
</body>
<script>
    layui.use(['upload', 'form'], function () {
        var $ = layui.jquery
            , upload = layui.upload
            , form = layui.form;
        //图片上传
        var uploadInst = upload.render({
            elem: '#test1'
            , url: 'users_top'
            , accept: 'file'
            , exts: 'xls|csv'
            , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#demo1').attr('src', result); //图片链接（base64）
                });
            }
            , done: function (res) {
                //如果上传失败
                if (res.status > 0) {
                    return layer.msg(res.msg);
                }
                //上传成功
                return layer.msg(res.msg);
            }
            , error: function () {
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            }
        });
    });
    function showimg(imgs) {
        console.log(imgs);
        layer.open({
            type: 1,
            title: false,
            shadeClose: true,
            skin: 'layui-layer-nobg', //没有背景色
            content: "<img src='" + imgs + "' style='width:100%;height: 100%;'>"
        });
    }
    function orderstr(url, user_id, type) {
        layer.prompt({
            value: '0',
            title: '请写入需要修改的数量，大于0表示增加，小于0表示减少',
        }, function (value, index, elem) {
            $.post(url, { user_id: user_id, type: type, money: value }, function (data) {
                if (data.status == 0) {
                    layer.msg(data.msg, { icon: 6, time: 1000 }, function () {
                        location.reload();
                        layer.close(index);
                    });
                } else {
                    layer.msg(data.msg, { icon: 2, time: 1000 });
                }
            });
        });
    }
</script>
{include file="public/footer"}